package tech.aistar.mapper.applyTourist;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.entity.User.Register;
import tech.aistar.entity.authordis.UserTable;
import tech.aistar.entity.daoyou.GuideApply;
import tech.aistar.entity.daoyou.UserIdcard;

/**
 * Created by lenovo on 2019/10/5.
 */
public interface ApplyTouristMapper {

    //插入导游申请表
    @Insert("insert into guide_apply(current_address,guide_phone,user_id,actual_name,birthplace,sex) values (#{address},#{phone},#{userId},#{name},#{birthplace},#{sex})")
    void insert(@Param("address")String address,@Param("phone")String phone,@Param("userId")Integer userId,@Param("name")String name,@Param("birthplace")String bithplace,@Param("sex")String sex);

    //从用户表里根据phone查id看是否为用户
    @Select("select id from user_table where phone=${values}")
    UserTable findByPhone(String phone);

    @Insert("insert into register(phone,email,ver_code) values (#{phone},#{email},#{code})")
    void insertregister(@Param("phone")String phoneNumber,@Param("email")String email,@Param("code")String ver_code);

    @Select("select * from register where ver_code=#{code} and phone=#{phone}")
    Register findByCode(@Param("code") String Code, @Param("phone")String phoneNumber);

    @Select("select * from user_table where phone=#{value}")
    UserTable findId(String phone);

    @Insert("insert into user_idcard(user_id,name,address,birth,idcard,nation,sex) values(#{userId},#{name},#{address},#{Birth},#{IDCard},#{nation},#{sex})")
    void save(@Param("userId")Integer userId,@Param("name")String name,@Param("address")String address,@Param("Birth")String Birth,@Param("IDCard")String IDCard,@Param("nation")String nation,@Param("sex")String sex);

    @Select("select * from user_idcard where user_id=#{value}")
    UserIdcard findById(Integer userId);

    @Select("select * from guide_apply where actual_name=#{value}")
    GuideApply findGuideId(String name);

    @Insert("insert into guide_info(guide_id,photo,profile) values (#{guideId},#{photo},#{profile})")
    void saveGuideInfo(@Param("guideId")Integer guideId,@Param("photo")String photo,@Param("profile")String profile);

    @Select("select * from user_idcard where name=#{value}")
    UserIdcard findUser(String name);

}
